using Cysharp.Threading.Tasks;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public partial class SystemPanel : UIPanel
{
    private const string path = "Assets/Prefab/SystemPanel.prefab";

    public SystemPanel() : base(new(path))
    {
    }
    public override void OnEnter()
    {
        base.OnEnter();

        ParentRectTransform.gameObject.SetActive(false);

        FuncGroup funcGroup = new FuncGroup();
        funcGroup.Bind(m_FuncGroup);

        AddInputEventCallback();
    }
    public override void OnPause()
    {
        base.OnPause();

        RemoveInputEventCallback();
    }
    public override void OnResume()
    {
        base.OnResume();

        AddInputEventCallback();
    }
    public async override UniTask OnStop(bool useAnim)
    {
        await base.OnStop(useAnim);

        ParentRectTransform.gameObject.SetActive(true);

        RemoveInputEventCallback();
    }
    private void AddInputEventCallback()
    {
        m_ExitButton.onClick.AddListener(async() =>
        {
            await PanelManager.Instance.ClosePanel(this);
        });
    }
    private void RemoveInputEventCallback()
    {
        m_ExitButton.onClick.RemoveAllListeners();
    }
}
